Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
¿Cómo implementar condiciones con operadores booleanos "y" y "o"?

¿Cómo puedo implementar una condición usando operadores booleanos and or usando firestore?

Un ejemplo de lo que quiero hacer:

 this.itemsCollection = this.afs.collection<Message>('messages', ref => { let query: firebase.default.firestore.CollectionReference | firebase.default.firestore.Query = ref; query = ((query.where('senderId', '==', this._cs.senderId || '') && query.where('receiverId', '==', this.receiverId || '')) || (query.where('receiverId', '==', this._cs.senderId || '') && query.where('senderId', '==', this.receiverId || ''))) return query; }) this.items = this.itemsCollection.valueChanges();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No hay opción para hacer un OR en diferentes campos en Firestore. Tendrá que ejecutar múltiples consultas para esto y luego fusionar los resultados en el código de su aplicación.

Verificar un OR para múltiples valores en un solo campo se denomina in condición en Firestore y se puede hacer con:

 query.where('senderId', 'in', [this._cs.senderId, ''])

La cadena vacía aquí debe existir literalmente en el documento para que coincida con la condición. No hay forma de filtrar documentos donde no existe senderId , ya que los documentos sin un valor para ese campo simplemente no existirán en el índice que Firestore creó para senderId .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!